//
//  AccountListTableViewCell.m
//  HYApp
//
//  Created by Jianbo Cai on 2020/8/6.
//  Copyright © 2020 Unidax. All rights reserved.
//

#import "AccountListTableViewCell.h"

@interface AccountListTableViewCell()

@property (weak, nonatomic) IBOutlet UIView *bgView;

@property (weak, nonatomic) IBOutlet UILabel *totalTitle;
@property (weak, nonatomic) IBOutlet UILabel *availableTitle;
@property (weak, nonatomic) IBOutlet UIButton *depositButton;
@property (weak, nonatomic) IBOutlet UIButton *transferButton;
@property (weak, nonatomic) IBOutlet UIButton *withdrawButton;


@end

@implementation AccountListTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    [self.exchangeButton setTitleColor:UIColorFromHex(0xCCCCCC) forState:UIControlStateDisabled];
    
    self.totalTitle.text = JFMainLocalizedString(@"myAssets.total");
    self.availableTitle.text = JFMainLocalizedString(@"myAssets.available");
    [self.depositButton setTitle:JFMainLocalizedString(@"deposit.deposit") forState:UIControlStateNormal];
    [self.exchangeButton setTitle:JFMainLocalizedString(@"exchange.exchange") forState:UIControlStateNormal];
    [self.transferButton setTitle:JFMainLocalizedString(@"withdraw.transfer") forState:UIControlStateNormal];
    [self.withdrawButton setTitle:JFMainLocalizedString(@"withdraw.withdraw") forState:UIControlStateNormal];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setEntity:(BalanceListEntity *)entity {
    _entity = entity;
    
    [self.image setImage:[UIImage imageNamed:entity.imageName]];
    self.market.text = entity.asset_address;
    self.totalVaule.text = MoneyFormat(entity.indicative_usd_equivalent);
    self.availableVaule.text = MoneyFormat(entity.available_balance_display);
}

- (IBAction)depositAction:(id)sender {
    if (self.action) {
        self.action(FunctionActionTypeDeposit);
    }
}

- (IBAction)exchangeAction:(id)sender {
    if (self.action) {
        self.action(FunctionActionTypeExchange);
    }
}

- (IBAction)transferAction:(id)sender {
    if (self.action) {
        self.action(FunctionActionTypeTransfer);
    }
}

- (IBAction)withdrawAction:(id)sender {
    if (self.action) {
        self.action(FunctionActionTypeWithdraw);
    }
}

@end
